<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">


      <el-form-item label="科室名称" prop="name">
        <el-select v-model="queryParams.code" placeholder="请选择科室名称" clearable size="small">
          <el-option
            v-for="dict in dict.type.科室"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="日期" prop="createDatetime">
        <el-date-picker
          v-model="queryParams.createDatetime"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <!--数据表格-->
    <el-table v-loading="loading" :data="ghQueryList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="就诊卡号" align="center" prop="cardId" />
      <el-table-column label="姓名" align="center" prop="name" />
      <el-table-column label="科室" align="center" prop="bmName" />
      <el-table-column label="门诊类型" align="center" prop="registerType" />
      <el-table-column label="就诊医生" align="center" prop="doctor" />
      <el-table-column label="创建时间" align="center" prop="createDatetime" />
      <el-table-column label="创建人" align="center" prop="operatorName" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import {ghQuery} from "@/api/his/ghQuery";

export default {
  name: "GhQuery",
  dicts: ['科室'],
  data() {
    return {
      // 遮罩层
      loading: false,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 挂号记录表格数据
      ghQueryList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        createDatetime: null,
        createDatetime2: null,
        code:null,
      },
      // 表单参数
      form: {},
    };
  },
  created() {
    // this.getList();
  },
  methods: {
    /** 查询挂号记录列表 */
    getList() {
      const data = {
        pageNum: this.queryParams.pageNum,
        pageSize: this.queryParams.pageSize,
        createDatetime: this.queryParams.createDatetime[0]+"",
        createDatetime2: this.queryParams.createDatetime[1]+"",
        code:this.queryParams.code,
      }

      this.loading = true;
      ghQuery(data).then(response => {
        this.ghQueryList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
  }
};
</script>
